﻿package mortal.game.manager
{
    import __AS3__.vec.*;
    import flash.display.*;
    import mortal.component.window.*;
    import mortal.game.scene3D.map3D.*;
    import mortal.mvc.core.*;
    import mortal.mvc.interfaces.*;

    public class MainUILayer extends View implements ILayer
    {
        private var vcDisplaObject:Vector.<DisplayObject>;
        public var isSmallSize:Boolean = false;
        public var isSmallHeight:Boolean = false;

        public function MainUILayer()
        {
            this.vcDisplaObject = new Vector.<DisplayObject>;
            return;
        }// end function

        public function addPopUp(param1:DisplayObject, param2:Boolean = false) : void
        {
            if (param1 && this.contains(param1) == false)
            {
                this.addChild(param1);
                if (param1 is View)
                {
                    (param1 as View).stageResize();
                }
                this.vcDisplaObject.push(param1);
            }
            return;
        }// end function

        public function centerPopup(param1:DisplayObject) : void
        {
            return;
        }// end function

        public function setPosition(param1:DisplayObject, param2:int, param3:int) : void
        {
            param1.x = param2;
            param1.y = param3;
            return;
        }// end function

        public function isTop(param1:DisplayObject) : Boolean
        {
            if (this.contains(param1))
            {
                return this.getChildIndex(param1) == (this.numChildren - 1);
            }
            return false;
        }// end function

        public function removePopup(param1:DisplayObject, param2:Boolean = true) : void
        {
            var _loc_3:int = 0;
            if (this.contains(param1))
            {
                this.removeChild(param1);
                _loc_3 = this.vcDisplaObject.indexOf(param1);
                if (_loc_3 >= 0)
                {
                    this.vcDisplaObject.splice(_loc_3, 1);
                }
            }
            return;
        }// end function

        public function isPopup(param1:DisplayObject) : Boolean
        {
            return this.contains(param1);
        }// end function

        public function setTop(param1:DisplayObject) : void
        {
            if (this.contains(param1))
            {
                if (this.getChildIndex(param1) != (this.numChildren - 1))
                {
                    this.setChildIndex(param1, (this.numChildren - 1));
                }
            }
            return;
        }// end function

        override public function stageResize() : void
        {
            var _loc_2:int = 0;
            this.isSmallSize = SceneRange.display.width < 1200;
            this.isSmallHeight = SceneRange.display.height < 700;
            var _loc_1:* = this.vcDisplaObject.length;
            _loc_2 = 0;
            while (_loc_2 < _loc_1)
            {
                
                if (this.vcDisplaObject[_loc_2] is IStageResize && this.vcDisplaObject[_loc_2] is View)
                {
                    (this.vcDisplaObject[_loc_2] as View).stageResize();
                }
                _loc_2++;
            }
            return;
        }// end function

        public function removeAllWindow() : void
        {
            var _loc_3:Window = null;
            var _loc_1:* = this.numChildren;
            var _loc_2:* = _loc_1 - 1;
            while (_loc_2 >= 0)
            {
                
                _loc_3 = this.getChildAt(_loc_2) as Window;
                if (_loc_3)
                {
                    _loc_3.hide();
                }
                _loc_2 = _loc_2 - 1;
            }
            return;
        }// end function

    }
}
